<template>
	<div class="carry">
        <div class="redList">
        	<ul v-for="(item,index) in redListist">
        		<li @click="openDialog(index,item)">抢红包</li>
        	</ul>
        </div>
		<bottom-nav></bottom-nav>
	</div>
</template>

<script>
	import bottomNav from './bottomNav'
	import { MessageBox } from 'mint-ui'
	import router from "../router"
	export default {
		name: 'carry',
		data () {
			return {
				'redListist':['','','','','','','','','','','','',]
			}
		},
		components: {bottomNav},
		mounted () {
			this.userInfo = JSON.parse(window.localStorage.getItem("userInfo"));
			var that = this;
			var str = window.location.href ;
			var temp = str.charAt(str.length-1);
			this.axios({
				 method:'post',
				 url:"http://xyydj.daoapp.io/mobile/redpacket/list",
				 data:{
					 "openid":that.userInfo.openid,
					 "spieltag":temp
				 }
			}).then(function(res){
					console.log(res)
					that.redListist = res.data.data;
			})
			// var that = this;
			// var temp = str.split(str.lastIndexOf("\\")) +1 ;
			// console.log(temp)
			// var result = 
		
			// this.axios({
			// 	 method:'post',
			// 	 url:"http://xyydj.daoapp.io/mobile/redpacket/list",
			// 	 data:{
			// 		 "openid":"obj8zs1IdUy8DE6a8j0C1eiQIQUQ",
			// 		 "spieltag":
			// 	 }
			// }).then(function(res){
			// 		console.log(res.data.data)
			// 		that.redListist = res.data.data;
			// })
			this.redListist = temp;
		},
		created() {

		},
		methods: {
			openDialog(index,item) {
				console.info(item)
				MessageBox({
					message: '<p>拆红包</p>',
					title: '',
					dialogClass: 'carry1Dialog',
					confirmButtonText: '',
					cancelButtonText: ''
				}).then(action => {
				  if(action === 'confirm'){
				  	var packetNumber = "<p>恭喜您<br>获得"+item.sum+"金币</p>" 
		  			MessageBox({
					message:packetNumber,
					title: '',
					dialogClass: 'carry2Dialog',
					showCancelButton: true,
					confirmButtonText: '',
					cancelButtonText: ''
				}).then((action) => {
				    console.log('action: ', action);
				    if(action == 'confirm'){
					  	this.$router.push({path: '/page2',param:index});
				    }else if(action == "cancel"){
					  	this.$router.push({path: '/',param:index});
				    }
				});
				  }
				});
			}
		}
	}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.carry{padding-top: 16.4rem;background: url(../assets/img/bg3Top.png) top center no-repeat, url(../assets/img/bg1Bottom.jpg) bottom center no-repeat;background-size: 100% auto;width: 100%;box-sizing: border-box;overflow: hidden;}
.redList{width: 100%;}
.redList li{margin: .9rem 1.8rem;float: left;padding-top: 4.5rem;text-indent: -4px;background: url(../assets/img/red1.png) 0 0 no-repeat;background-size: 5.65rem auto;width: 5.65rem;height: 8.15rem;font-size: 1.3rem;color: #ea2929;text-align: center;box-sizing: border-box;}
</style>
